package cn.cycleif.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;


@Getter
public enum UserStatusEnum implements IEnum<Integer> {
  DISABLE(0, "禁用", "BANNED"),
  ACTIVE(1, "启用", "ACTIVE"),
  PENDING(2, "审核中", "PENDING");

  private final int    code;
  private final String desc;
  @JsonValue
  private final String sign;

  UserStatusEnum(int code, String desc, String sign) {
    this.code = code;
    this.desc = desc;
    this.sign = sign;
  }

  public static UserStatusEnum fromCode(Integer code) {
    for (UserStatusEnum userStatusEnum : UserStatusEnum.values()) {
      if (userStatusEnum.getValue()
                        .equals(code)) {
        return userStatusEnum;
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.code;
  }
}
